package lc.贪心;

import java.util.Arrays;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/10/7
 */
public class Math322零钱兑换 {

    public int coinChange(int[] coins, int amount) {

        Arrays.sort(coins);
        int i = coins.length -1;
        int count = 0;
        while (i >= 0) {
            if (amount < coins[i]) {
                i--;
                continue;
            }
            amount -= coins[i];
            count++;
        }
        return count;
    }
}
